package com.lun.blog.service.impl;

import com.lun.blog.repostory.UserRepository;
import com.lun.blog.pojo.User;
import com.lun.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public User checked(String username, String password) {
        return userRepository.findByUsernameAndPassword(username,password);
    }

    @Override
    public User findByUserId(Long userId) {
        Optional<User> user = userRepository.findById(userId);
        return user.isPresent()?user.get():null;
    }

    @Override
    public List<User> findByUserIds(Set<Long> userId) {
        return userRepository.findByIdIn(userId);
    }
}
